package demo06234;

import java.util.Scanner;

public class PaymentTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double amount = 20.00;

        Payment bankCard = new BankCardPayment(100.00, "622588******1234");
        Payment alipay = new AlipayPayment(15.00, "alipay@example.com");
        Payment wechat = new WechatPayment(30.00, "wx_2023001");

        System.out.println("=== 支付系统 ===");
        System.out.printf("当前需支付金额: %.2f元\n", amount);
        System.out.println("请选择支付方式:");
        System.out.println("1. 银行卡支付");
        System.out.println("2. 支付宝支付");
        System.out.println("3. 微信支付");
        System.out.print("请输入选择(1-3): ");

        int choice = scanner.nextInt();
        Payment selectedPayment = null;


        switch (choice) {
            case 1:
                selectedPayment = bankCard;
                break;
            case 2:
                selectedPayment = alipay;
                break;
            case 3:
                selectedPayment = wechat;
                break;
            default:
                System.out.println("无效的选择!");
                System.exit(0);
        }

        System.out.println("\n您选择了: " + selectedPayment.getPaymentName());
        System.out.printf("当前余额: %.2f元\n", selectedPayment.getBalance());


        boolean result = selectedPayment.pay(amount);


        if (result) {
            System.out.printf("支付成功! 剩余余额: %.2f元\n", selectedPayment.getBalance());
        }

        scanner.close();
    }
}